package org.example.server.goods.mapstruct.snapshot.detail;

import org.example.frw.canal.binlog.entity.GoodsDetailBinlogEntity;
import org.example.server.goods.entity.snapshot.GoodsDetailSnapshotEntity;
import org.example.server.goods.mapstruct.snapshot.BaseConverter;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.factory.Mappers;

@Mapper(componentModel = "spring",nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface GoodsDetailSnapshotConverter extends BaseConverter {
  /**
   * 转换实例
   */
  GoodsDetailSnapshotConverter INSTANCE = Mappers.getMapper(GoodsDetailSnapshotConverter.class);

  @Mapping(target = "id",ignore = true)
  @Mapping(target = "detailId",source = "id")
  @Mapping(target = "createTime", source = "createTime", qualifiedByName = "stringToDate")
  @Mapping(target = "updateTime", source = "updateTime", qualifiedByName = "stringToDate")
  GoodsDetailSnapshotEntity toGoodsDetailSnapshotEntity(GoodsDetailBinlogEntity goodsEntity);
}
